/**
 * creater:chuanpeng.zhu@dhc.com.cn
 * create time:2016-06-12 13:02:48
 * describe:时间轴实例
 */
APP.controller('TimeLineController', ['$scope', 'TimeLineService',
  function ($scope, TimeLineService) {

    /***变量声明***/
    $scope.local = undefined;

    /**
     * 初始化函数
     */
    $scope.init = function () {
      $scope.local = [{
        img: 'img/app_zcp.png',
        dateTime: '2016-04-12 16:20:12',
        content: '【提交订单】'
      }, {
        img: 'img/app_wh.png',
        dateTime: '2016-04-12 17:20:12',
        content: '【确认订单】'
      }, {
        icon: 'icon ion-social-octocat',
        dateTime: '2016-04-12 18:20:12',
        content: '【取消订单】'
      }, {
        icon: 'icon ion-social-tux',
        dateTime: '2016-04-12 18:20:12',
        content: '【取消订单】取消订单取消订单取消订单取消订单取消订单取消订单取消订单取消订单取消订单取消订单取消订单取消订单取消订单'
      }, {
        icon: 'icon ion-social-android',
        dateTime: '2016-04-12 18:20:12',
        content: '【取消订单】'
      }, {
        icon: 'icon ion-social-apple',
        dateTime: '2016-04-12 18:20:12',
        content: '【取消订单】'
      }, {
        icon: 'icon ion-model-s',
        dateTime: '2016-04-12 18:20:12',
        content: '【取消订单】取消订单取消订单取消订单取消订单取消订单取消订单取消订单取消订单取消订单取消订单取消订单取消订单取消订单'
      }, {
        icon: 'icon ion-jet',
        dateTime: '2016-04-12 18:20:12',
        content: '【取消订单】'
      }];
    };


    /*
     $scope.init();//如果页面缓存则用此方法初始化
     */
    $scope.$on('$ionicView.beforeEnter', function () {
      $scope.init();
    });
  }
]);


APP.controller('example1', ['$scope', 'TimeLineService',
  function ($scope, TimeLineService) {
    $scope.data = $scope.local;
    $scope.getIcon = function (index) {
      return $scope.data[index].icon;
    };
    $scope.getImage = function (index) {
      return $scope.data[index].img;
    };
    $scope.getDateTime = function (index) {
      return $scope.data[index].dateTime;
    };
    $scope.getContent = function (index) {
      return $scope.data[index].content;

    };
  }
]);

APP.controller('example2', ['$scope', 'TimeLineService',
  function ($scope, TimeLineService) {
    $scope.data = $scope.$parent.local;
    $scope.getIcon = function (index) {
      return $scope.data[index].icon;
    };
    $scope.getImage = function (index) {
      return $scope.data[index].img;
    };
    $scope.getDateTime = function (index) {
      return $scope.data[index].dateTime;
    };
    $scope.getContent = function (index) {
      return $scope.data[index].content;

    };

  }
]);

/**
 * creater:chuanpeng.zhu@dhc.com.cn
 * create time:2016-06-12 13:02:48
 * describe:时间轴实例
 */
APP.service('TimeLineService', ['$http', 'UrlService', function ($http, UrlService) {
  /**
   * 登录方法
   * @param username  登录用户名
   * @param password  登录密码
   */
  this.doLogin = function (username, password) {
    var param = {
      username: username,
      password: password
    };
    $http.post(UrlService.getUrl('LOGIN'), param);
  }

}]);
